var amqp = require('amqplib/callback_api');

amqp.connect('amqp://localhost', function(err, conn) {
  conn.createChannel(function(err, ch) {
    var tq = 'task_queue';
    var url = process.argv[2];
    var isDynamic = process.argv[3]?true:false;
    console.log(url);
    var msg = {};
    msg.url = url;
    msg.isDynamic = isDynamic;
    console.log(msg);
    ch.assertQueue(tq, {durable: true});
    ch.sendToQueue(tq, new Buffer(JSON.stringify(msg)), {persistent: true});
    console.log(" [x] Sent '%s'", msg.url);
  });
  setTimeout(function() { conn.close(); process.exit(0) }, 500);
});
